<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="author" content="esy">
    
    <meta name="description" content="esy">
    
    
    
    
    
    
    <title>HMM之数据的处理 | ESY</title>
    <link href="https://esyyes.github.io" rel="prefetch" />

    
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/aos.css">
<link rel="stylesheet" href="/css/style.css">

    
<script src="/js/jquery.min.js"></script>

    
<script src="/js/bootstrap.min.js"></script>

    
<script src="/js/aos.js"></script>

    
<script src="/js/highslide/highslide-full.min.js"></script>

    
<link rel="stylesheet" href="/js/highslide/highslide.css">

    <style type="text/css">
        @media (max-width: 768px) {
            body {
                background-color: #f0f0f0;
                background: url('/imgs/xsbg.gif');
                background-attachment: fixed;
            }
        }
    </style>
    
    <!--<script type="text/javascript">
      if (document.images) {
        var avatar = new Image();
        avatar.src = '/imgs/avatar.jpg'
        var previews = 'preview1.jpg,preview2.jpg,preview3.jpg,preview4.jpg'.split(',')
        var previewsPreLoad = []
        for(var i = 0; i < length; i++) {
          previewsPreLoad.push(new Image())
          previewsPreLoad[previewsPreLoad.length - 1].src = '/imgs/preview' + previews[i]
        }
      }
    </script>-->
<meta name="generator" content="Hexo 5.2.0"></head>
<body>
    <!-- 背景轮播图功能 -->
    <section class="hidden-xs">
    <ul class="cb-slideshow">
        <li><span>天若</span></li>
        <li><span>有情</span></li>
        <li><span>天亦老</span></li>
        <li><span>我为</span></li>
        <li><span>长者</span></li>
        <li><span>续一秒</span></li>
    </ul>
</section>
    <!-- 欧尼酱功能, 谁用谁知道 -->
    
    <div class="gal-menu gal-dropdown">
    <div class="circle" id="gal">
        <div class="ring">
            <a href="https://esyyes.github.io" class="menuItem" style="left: 50%; top: 15%;">首页</a>
            
            <a class="menuItem" style="left: 80.3109%; top: 32.5%;">下一页</a>
            
            <a href="/archives" class="menuItem" style="left: 80.3109%; top: 67.5%;">归档</a>
            <a href="/about" class="menuItem" style="left: 50%; top: 85%;">关于</a>
            <a href="/message" class="menuItem" style="left: 19.6891%; top: 67.5%;">留言板</a>

            
            <a class="menuItem" style="left: 19.6891%; top: 32.5%;">上一页</a>
            
        </div>
        <audio id="audio" src="/imgs/oni.mp3"></audio>
    </div>
</div>
    
    <header class="navbar navbar-inverse" id="gal-header">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed"
                    data-toggle="collapse" data-target=".bs-navbar-collapse"
                    aria-expanded="false">
                <span class="fa fa-lg fa-reorder"></span>
            </button>
            <a href="https://esyyes.github.io">
                
                <style>
                    #gal-header .navbar-brand {
                        height: 54px;
                        line-height: 24px;
                        font-size: 28px;
                        opacity: 1;
                        background-color: rgba(0,0,0,0);
                        text-shadow: 0 0 5px #fff,0 0 10px #fff,0 0 15px #fff,0 0 20px #228DFF,0 0 35px #228DFF,0 0 40px #228DFF,0 0 50px #228DFF,0 0 75px #228DFF;
                    }
                </style>
                <!-- 这里使用文字(navbar_text or config.title) -->
                <div class="navbar-brand">ESY</div>
                
            </a>
        </div>
        <div class="collapse navbar-collapse bs-navbar-collapse">
            <ul class="nav navbar-nav" id="menu-gal">
                
                
                <li class="">
                    <a href="/">
                        <i class="fa fa-home"></i>首页
                    </a>
                </li>
                
                
                
                <li class="">
                    <a href="/archives">
                        <i class="fa fa-archive"></i>归档
                    </a>
                </li>
                
                
                
                
                <li class="dropdown">
                    <!-- TODO 添加hover dropdown效果 -->
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown"
                       aria-haspopup="true" aria-expanded="false" data-hover="dropdown">
                        <i class="fa fa-list"></i>分类
                    </a>
                    <ul class="dropdown-menu">
                        
                        
                        <li>
                            <a href="/categories/py-study/">py_study</a>
                        </li>
                        
                        <li>
                            <a href="/categories/nlp/">nlp</a>
                        </li>
                        
                        <li>
                            <a href="/categories/Graduation-work/">Graduation work</a>
                        </li>
                        
                        <li>
                            <a href="/categories/work/">work</a>
                        </li>
                        
                        <li>
                            <a href="/categories/hexo/">hexo</a>
                        </li>
                        
                        <li>
                            <a href="/categories/hexo%E5%AE%8C%E5%96%84/">-hexo完善</a>
                        </li>
                        
                        
                        <li>
                            <a href="/categories">...</a>
                        </li>
                        
                        
                    </ul>
                </li>
                
                
                
                
                
                <li class="dropdown">
                    <!-- TODO 添加hover dropdown效果 -->
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown"
                       aria-haspopup="true" aria-expanded="false" data-hover="dropdown">
                        <i class="fa fa-tags"></i>标签
                    </a>
                    <ul class="dropdown-menu">
                        
                        
                        <li>
                            <a href="/tags/py-study/">py_study</a>
                        </li>
                        
                        <li>
                            <a href="/tags/nlp/">nlp</a>
                        </li>
                        
                        <li>
                            <a href="/tags/Graduation-work/">Graduation work</a>
                        </li>
                        
                        <li>
                            <a href="/tags/work/">work</a>
                        </li>
                        
                        <li>
                            <a href="/tags/hexo/">hexo</a>
                        </li>
                        
                        <li>
                            <a href="/tags/%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA/">-个人博客搭建</a>
                        </li>
                        
                        
                        <li>
                            <a href="/tags">...</a>
                        </li>
                        
                        
                    </ul>
                </li>
                
                
                
                
                <li class="">
                    <a href="/about">
                        <i class="fa fa-user"></i>关于我
                    </a>
                </li>
                
                
            </ul>
        </div>
    </div>
</header>
    <div id="gal-body">
        <div class="container">
            <div class="row">
                <div class="col-md-8 gal-right" id="mainstay">
                    
<article class="article well article-body" id="article">
    <div class="breadcrumb">
        <i class="fa fa-home"></i>
        <a href="https://esyyes.github.io">ESY</a>
        >
        <span>HMM之数据的处理</span>
    </div>
    <!-- 大型设备详细文章 -->
    <div class="hidden-xs">
        <div class="title-article">
            <h1>
                <a href="/2020/07/09/python%20work/HMM%E4%B9%8B%E6%95%B0%E6%8D%AE%E7%9A%84%E5%A4%84%E7%90%86/">HMM之数据的处理</a>
            </h1>
        </div>
        <div class="tag-article">
            
            <span class="label label-gal">
                <i class="fa fa-tags"></i>
                
                <a href="/tags/work/">work</a>
                
            </span>
            
            <span class="label label-gal">
                <i class="fa fa-calendar"></i> 2020-07-09
            </span>
            
        </div>
    </div>
    <!-- 小型设备详细文章 -->
    <div class="visible-xs">
        <center>
            <div class="title-article">
                <h4>
                    <a href="/2020/07/09/python%20work/HMM%E4%B9%8B%E6%95%B0%E6%8D%AE%E7%9A%84%E5%A4%84%E7%90%86/">HMM之数据的处理</a>
                </h4>
            </div>
            <p>
                <i class="fa fa-calendar"></i> 2020-07-09
            </p>
            <p>
                
                <i class="fa fa-tags"></i>
                
                <a href="/tags/work/">work</a>
                
                
                
            </p>
        </center>
    </div>
    <div class="content-article">
        <h1 id="HMM之数据的处理"><a href="#HMM之数据的处理" class="headerlink" title="HMM之数据的处理"></a>HMM之数据的处理</h1><h2 id="查看数据"><a href="#查看数据" class="headerlink" title="查看数据"></a>查看数据</h2><p>直接读取数据</p>
<p>数据类型如下所示：</p>
<table>
<thead>
<tr>
<th align="right"></th>
<th align="right">i</th>
<th align="right">t</th>
<th align="right">y</th>
<th align="right">x1</th>
<th align="right">x2</th>
<th align="right">x3</th>
<th align="right">x4</th>
<th align="right">z1</th>
<th align="right">z2</th>
</tr>
</thead>
<tbody><tr>
<td align="right">0</td>
<td align="right">1</td>
<td align="right">1</td>
<td align="right">0</td>
<td align="right">3891</td>
<td align="right">116</td>
<td align="right">0</td>
<td align="right">0</td>
<td align="right">6.0</td>
<td align="right">59.0</td>
</tr>
<tr>
<td align="right">1</td>
<td align="right">1</td>
<td align="right">2</td>
<td align="right">0</td>
<td align="right">5958</td>
<td align="right">93</td>
<td align="right">0</td>
<td align="right">0</td>
<td align="right">NaN</td>
<td align="right">NaN</td>
</tr>
<tr>
<td align="right">2</td>
<td align="right">1</td>
<td align="right">3</td>
<td align="right">0</td>
<td align="right">5362</td>
<td align="right">106</td>
<td align="right">0</td>
<td align="right">0</td>
<td align="right">NaN</td>
<td align="right">NaN</td>
</tr>
<tr>
<td align="right">3</td>
<td align="right">1</td>
<td align="right">4</td>
<td align="right">0</td>
<td align="right">2528</td>
<td align="right">126</td>
<td align="right">0</td>
<td align="right">0</td>
<td align="right">NaN</td>
<td align="right">NaN</td>
</tr>
<tr>
<td align="right">4</td>
<td align="right">1</td>
<td align="right">5</td>
<td align="right">1</td>
<td align="right">1219</td>
<td align="right">215</td>
<td align="right">0</td>
<td align="right">0</td>
<td align="right">NaN</td>
<td align="right">NaN</td>
</tr>
</tbody></table>
<h3 id="数据的含义"><a href="#数据的含义" class="headerlink" title="数据的含义"></a>数据的含义</h3><p>i对应的是一个人，t表示的是一个时期为一周，x1-x4,表示的是自变量，是影响隐马尔科夫模型的转移概率矩阵，z1,z2,是控制变量，是可以长期影响一个人的控制变量数据，是状态转移矩阵的估计量。</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">                  表 <span class="number">4</span><span class="number">-2</span> 变量的统计学描述                </span><br><span class="line">变量名		样本数		 均值		标准差		最小值		最大值</span><br><span class="line">y		<span class="number">3108</span>		<span class="number">1.119691</span>	<span class="number">6.266278</span>	<span class="number">0</span>		<span class="number">111</span></span><br><span class="line">x1		<span class="number">3108</span>		<span class="number">1301.892</span>	<span class="number">2582.350</span>	<span class="number">0</span>		<span class="number">42864</span></span><br><span class="line">x2		<span class="number">3108</span>		<span class="number">615.3838</span>	<span class="number">2130.248</span>	<span class="number">-58</span>		<span class="number">46162</span></span><br><span class="line">x3		<span class="number">3108</span>		<span class="number">1.071750</span>	<span class="number">4.706953</span>	<span class="number">0</span>		<span class="number">103</span></span><br><span class="line">x4		<span class="number">3108</span>		<span class="number">0.751609</span>	<span class="number">5.057782</span>	<span class="number">0</span>		<span class="number">90</span></span><br></pre></td></tr></table></figure>

<p>样本差异过大，所以需要进行归一化或者标准化处理</p>
<p>没有数据缺失，因此只需要进行标准化即可。</p>
<h3 id="数据标准化"><a href="#数据标准化" class="headerlink" title="数据标准化"></a>数据标准化</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">&quot;&quot;&quot;</span></span><br><span class="line"><span class="string">均值插补缺省值</span></span><br><span class="line"><span class="string">z-score标准化</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">&quot;&quot;&quot;</span></span><br><span class="line"><span class="keyword">import</span> pandas <span class="keyword">as</span> pd</span><br><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line"><span class="keyword">from</span> sklearn <span class="keyword">import</span> preprocessing</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">data_pre</span>(<span class="params">data</span>):</span></span><br><span class="line">    df = data.replace([np.inf, -np.inf], np.nan)</span><br><span class="line">    num = df.isnull().<span class="built_in">sum</span>()</span><br><span class="line">    [df[df.keys()[i]].fillna(value=df[df.keys()[i]].mean(), inplace=<span class="literal">True</span>) <span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="built_in">len</span>(num)) <span class="keyword">if</span> num[i] &gt; <span class="number">0</span>]</span><br><span class="line"></span><br><span class="line">    df_scale = preprocessing.scale(df)</span><br><span class="line">    <span class="comment"># 将标准化后的数据再转换为表格</span></span><br><span class="line">    fea = pd.DataFrame(df_scale, columns=data.keys())</span><br><span class="line">    <span class="keyword">return</span> fea</span><br></pre></td></tr></table></figure>

<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">         x1        x2        x3        x4</span><br><span class="line"><span class="number">0</span>  <span class="number">1.002617</span> <span class="number">-0.234425</span> <span class="number">-0.227695</span> <span class="number">-0.148604</span></span><br><span class="line"><span class="number">1</span>  <span class="number">1.803051</span> <span class="number">-0.245222</span> <span class="number">-0.227695</span> <span class="number">-0.148604</span></span><br><span class="line"><span class="number">2</span>  <span class="number">1.572253</span> <span class="number">-0.239119</span> <span class="number">-0.227695</span> <span class="number">-0.148604</span></span><br><span class="line"><span class="number">3</span>  <span class="number">0.474803</span> <span class="number">-0.229731</span> <span class="number">-0.227695</span> <span class="number">-0.148604</span></span><br><span class="line"><span class="number">4</span> <span class="number">-0.032099</span> <span class="number">-0.187952</span> <span class="number">-0.227695</span> <span class="number">-0.148604</span></span><br></pre></td></tr></table></figure>

<p>数据标准化后结果如上图所示</p>
<h3 id="HMM的状态划分"><a href="#HMM的状态划分" class="headerlink" title="HMM的状态划分"></a>HMM的状态划分</h3><p>在现实的数据中，HMM的隐藏状态是无法直接判别的，因此需要对状态进行判别。</p>
<p>在模型训练中最重要的步骤是进行模型状态数量的<br>确定。由于在大多数实验过程中，并不能直接确定将研究的隐藏状态分为几<br>个状态水平较为合适，因此，需要通过建立多个模型，根据贝叶斯信息准则<br>对模型的拟合效果进行比较，选择最佳的模型作为实际研究模型。</p>
<p>据相关研究，需要通过假定不同的状态量 S，建立若干个模<br>型，训练模型后计算模型的对数似然值。再根据贝叶斯信息准则（BIC）的<br>计算方法，计算 BIC 的值，比较后选择效果较好的模型。 </p>
<p> <strong>BIC =ln L − k× ln P / 2</strong>   </p>
<p>BIC 值的计算方法，其中 ln L 代表模型的对数<br>似然值，k 代表模型的变量个数，P 代表样本大小。BIC 的值越大，表示模<br>型训练的效果越好。</p>
<p>因此需要最大似然值和BIC进行估计，判断在什么状态下的数据最好。</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">根据样本数据。因此确定选择<span class="number">1</span>为阈值下</span><br><span class="line">均值下的似然估计值为：    <span class="number">-955.2942841591449</span></span><br><span class="line">分类为<span class="number">2</span>均值下的BIC为：	<span class="number">-1028.7801594684208</span></span><br><span class="line">变量：<span class="number">12</span></span><br><span class="line"><span class="number">1</span>值下的似然估计值为：    <span class="number">-1589.5001457084938</span></span><br><span class="line">分类为<span class="number">2</span>阈值为<span class="number">1</span>下的BIC为：<span class="number">-1662.9860210177699</span></span><br><span class="line">状态为<span class="number">3</span>时：设定<span class="number">1</span>《《标准差为阈值</span><br><span class="line">变量：<span class="number">18</span></span><br><span class="line">似然估计值为：    		<span class="number">-1486.947107953313</span></span><br><span class="line">分类为<span class="number">3</span>时的BIC为：		<span class="number">-1619.2216835100096</span></span><br><span class="line">状态为<span class="number">4</span>时：设定<span class="number">1</span>《《标准差《《方差为阈值</span><br><span class="line">变量：<span class="number">24</span></span><br><span class="line">似然估计值为： 		<span class="number">-1524.3108928288107</span> </span><br><span class="line">分类为<span class="number">4</span>时的BIC为：		<span class="number">-1700.676993571073</span></span><br></pre></td></tr></table></figure>

<p>因此确定3为状态数</p>
<h3 id="初始状态概率矩阵"><a href="#初始状态概率矩阵" class="headerlink" title="初始状态概率矩阵"></a>初始状态概率矩阵</h3><p>直接用划分的状态进行划分初始状态概率矩阵</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">当状态为<span class="number">2</span>时：</span><br><span class="line">[[<span class="number">0.7918275418275418</span>, <span class="number">0.20817245817245822</span>]]</span><br><span class="line">当状态为<span class="number">3</span>时：</span><br><span class="line">[[<span class="number">0.7918275418275418</span>, <span class="number">0.3462033462033462</span>, <span class="number">0.03507078507078507</span>]]</span><br><span class="line">当状态为<span class="number">4</span>时：</span><br><span class="line">[[<span class="number">0.7918275418275418</span>, <span class="number">0.3462033462033462</span>, <span class="number">0.030244530244530245</span>, <span class="number">0.004826254826254826</span>]]</span><br></pre></td></tr></table></figure>

<h3 id="判断最大似然的收敛性"><a href="#判断最大似然的收敛性" class="headerlink" title="判断最大似然的收敛性"></a>判断最大似然的收敛性</h3><p>用百次循环的结果去对应查看数据是否收敛</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">fig = plt.figure(figsize=(<span class="number">7</span>, <span class="number">4</span>))</span><br><span class="line"><span class="comment"># 解决中文显示问题</span></span><br><span class="line">plt.rcParams[<span class="string">&#x27;font.sans-serif&#x27;</span>] = [<span class="string">&#x27;Microsoft YaHei&#x27;</span>]</span><br><span class="line">plt.rcParams[<span class="string">&#x27;axes.unicode_minus&#x27;</span>] = <span class="literal">False</span></span><br><span class="line">plt.plot(list_L, <span class="string">&quot;bo&quot;</span>, linewidth=<span class="number">1</span>)</span><br><span class="line">plt.xlabel(<span class="string">&quot;Number of Iterations&quot;</span>, fontsize=<span class="number">10</span>)</span><br><span class="line">plt.xticks(fontsize=<span class="number">8</span>)</span><br><span class="line">plt.ylabel(<span class="string">&quot;Loglik&quot;</span>, fontsize=<span class="number">10</span>)</span><br><span class="line">plt.yticks(fontsize=<span class="number">8</span>)</span><br><span class="line"><span class="comment"># 去边框</span></span><br><span class="line">ax = plt.gca()</span><br><span class="line">ax.spines[<span class="string">&#x27;right&#x27;</span>].set_color(<span class="string">&#x27;none&#x27;</span>)</span><br><span class="line">ax.spines[<span class="string">&#x27;top&#x27;</span>].set_color(<span class="string">&#x27;none&#x27;</span>)</span><br><span class="line"></span><br><span class="line">plt.show()</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p><img src="H:\myboke\mybike\source\images\loglik.png" alt="loglik"></p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br><span class="line">255</span><br><span class="line">256</span><br><span class="line">257</span><br><span class="line">258</span><br><span class="line">259</span><br><span class="line">260</span><br><span class="line">261</span><br><span class="line">262</span><br><span class="line">263</span><br><span class="line">264</span><br><span class="line">265</span><br><span class="line">266</span><br><span class="line">267</span><br><span class="line">268</span><br><span class="line">269</span><br><span class="line">270</span><br><span class="line">271</span><br><span class="line">272</span><br><span class="line">273</span><br><span class="line">274</span><br><span class="line">275</span><br><span class="line">276</span><br><span class="line">277</span><br><span class="line">278</span><br><span class="line">279</span><br><span class="line">280</span><br><span class="line">281</span><br><span class="line">282</span><br><span class="line">283</span><br><span class="line">284</span><br><span class="line">285</span><br><span class="line">286</span><br><span class="line">287</span><br><span class="line">288</span><br><span class="line">289</span><br><span class="line">290</span><br><span class="line">291</span><br><span class="line">292</span><br><span class="line">293</span><br><span class="line">294</span><br><span class="line">295</span><br><span class="line">296</span><br><span class="line">297</span><br><span class="line">298</span><br><span class="line">299</span><br><span class="line">300</span><br><span class="line">301</span><br><span class="line">302</span><br><span class="line">303</span><br><span class="line">304</span><br><span class="line">305</span><br><span class="line">306</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># -*- coding: utf-8 -*-</span></span><br><span class="line"><span class="comment"># @Time     : 2020/7/9</span></span><br><span class="line"><span class="comment"># @Author   : esy</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">from</span> HMM_class <span class="keyword">import</span> *</span><br><span class="line"><span class="keyword">from</span> data_preprocessing <span class="keyword">import</span> *</span><br><span class="line"><span class="keyword">from</span> LR <span class="keyword">import</span> *</span><br><span class="line"><span class="comment"># import matplotlib.pyplot as plt</span></span><br><span class="line"><span class="keyword">import</span> math</span><br><span class="line"><span class="keyword">import</span> warnings</span><br><span class="line"></span><br><span class="line"><span class="comment"># 忽略警告</span></span><br><span class="line">warnings.filterwarnings(<span class="string">&quot;ignore&quot;</span>)</span><br><span class="line"></span><br><span class="line">data = pd.read_excel(<span class="string">&#x27;data1&#x27;</span> + <span class="string">&#x27;.xlsx&#x27;</span>)</span><br><span class="line">data.fillna(<span class="number">0</span>, inplace=<span class="literal">True</span>)</span><br><span class="line"><span class="comment"># 转换列表</span></span><br><span class="line">list_data = np.array(data).tolist()</span><br><span class="line">X1 = pd.get_dummies(data.iloc[<span class="number">0</span>:<span class="built_in">len</span>(data), <span class="number">3</span>:<span class="number">7</span>])</span><br><span class="line"></span><br><span class="line">X = data_pre(X1)</span><br><span class="line">Z = pd.get_dummies(data.iloc[<span class="number">0</span>:<span class="built_in">len</span>(data), <span class="number">7</span>:<span class="number">9</span>])</span><br><span class="line">list_y1 = [<span class="built_in">int</span>(list_data[i][<span class="number">2</span>]) <span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="built_in">len</span>(data))]</span><br><span class="line">y1_mean = np.array(list_y1).mean()</span><br><span class="line">y1_std = np.array(list_y1).std()</span><br><span class="line"><span class="comment"># 划分为状态3</span></span><br><span class="line"><span class="comment"># 状态1：小于1的</span></span><br><span class="line"><span class="comment"># 状态2：小于标准差</span></span><br><span class="line"><span class="comment"># 状态3：大于标准差</span></span><br><span class="line"></span><br><span class="line">Y_X = []</span><br><span class="line">num1 = <span class="number">0</span></span><br><span class="line">num2 = <span class="number">0</span></span><br><span class="line">num3 = <span class="number">0</span></span><br><span class="line"><span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="built_in">len</span>(data)):</span><br><span class="line">    <span class="keyword">if</span> list_data[i][<span class="number">2</span>] &lt; <span class="number">1</span>:</span><br><span class="line">        Y_X.append(<span class="number">0</span>)</span><br><span class="line">        num1 += <span class="number">1</span></span><br><span class="line">    <span class="keyword">elif</span> <span class="number">1</span> &lt;= list_data[i][<span class="number">2</span>] &lt; y1_std:</span><br><span class="line">        Y_X.append(<span class="number">1</span>)</span><br><span class="line">        num2 += <span class="number">2</span></span><br><span class="line">    <span class="keyword">else</span>:</span><br><span class="line">        Y_X.append(<span class="number">2</span>)</span><br><span class="line">        num3 += <span class="number">1</span></span><br><span class="line">Z1 = [[<span class="built_in">int</span>(list_data[<span class="number">14</span>*j][k]) <span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="built_in">len</span>(data)) <span class="keyword">if</span> <span class="number">14</span> * j == i <span class="keyword">for</span> k <span class="keyword">in</span> <span class="built_in">range</span>(<span class="number">7</span>, <span class="number">9</span>)]</span><br><span class="line">      <span class="keyword">for</span> j <span class="keyword">in</span> <span class="built_in">range</span>(<span class="built_in">int</span>(<span class="built_in">len</span>(data)/<span class="number">14</span>))]</span><br><span class="line">Z2 = pd.DataFrame(Z1, columns=[<span class="string">&#x27;z1&#x27;</span>, <span class="string">&#x27;z2&#x27;</span>])</span><br><span class="line">Z = data_pre(Z2)</span><br><span class="line"></span><br><span class="line"><span class="comment"># 将14个时期取平均值</span></span><br><span class="line">list_z_y = []</span><br><span class="line"><span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="built_in">int</span>(<span class="built_in">len</span>(data)/<span class="number">14</span>)):</span><br><span class="line">    y1 = []</span><br><span class="line">    <span class="keyword">for</span> j <span class="keyword">in</span> <span class="built_in">range</span>(<span class="built_in">len</span>(data)):</span><br><span class="line">        <span class="keyword">if</span> <span class="number">14</span> * i &lt;= j &lt; <span class="number">14</span> * (i + <span class="number">1</span>):</span><br><span class="line">            y1.append(list_data[j][<span class="number">2</span>])</span><br><span class="line">    list_z_y.append(np.array(y1).mean())</span><br><span class="line">Y_Z = []</span><br><span class="line"><span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="built_in">len</span>(list_z_y)):</span><br><span class="line">    <span class="keyword">if</span> list_z_y[i] &lt; <span class="number">1</span>:</span><br><span class="line">        Y_Z.append(<span class="number">0</span>)</span><br><span class="line">    <span class="keyword">elif</span> <span class="number">1</span> &lt;= list_z_y[i] &lt; y1_std:</span><br><span class="line">        Y_Z.append(<span class="number">1</span>)</span><br><span class="line">    <span class="keyword">else</span>:</span><br><span class="line">        Y_Z.append(<span class="number">2</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment"># HMM模型参数设置</span></span><br><span class="line">HMM = HiddenMarkov()</span><br><span class="line">Q = [<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>]</span><br><span class="line">V = [<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>]</span><br><span class="line">B = [[<span class="number">0.8767222625090645</span>, <span class="number">0.12327773749093547</span>, <span class="number">0.0</span>],</span><br><span class="line">     [<span class="number">0.17063492063492064</span>, <span class="number">0.75</span>, <span class="number">0.07936507936507937</span>],</span><br><span class="line">     [<span class="number">0.0</span>, <span class="number">0.09183673469387756</span>, <span class="number">0.9081632653061223</span>]]</span><br><span class="line">PI = [[num1/<span class="built_in">len</span>(data), num2/<span class="built_in">len</span>(data), num3/<span class="built_in">len</span>(data)]]</span><br><span class="line"></span><br><span class="line">list_L = []</span><br><span class="line">list_fix_x = []</span><br><span class="line">list_fix_z = []</span><br><span class="line">list_lr_x_w = []</span><br><span class="line">list_lr_z_w = []</span><br><span class="line">list_lr_x_b = []</span><br><span class="line">list_lr_z_b = []</span><br><span class="line">list_A = []</span><br><span class="line">list_BIC = []</span><br><span class="line">list_acr_x = []</span><br><span class="line">list_acr_z = []</span><br><span class="line"></span><br><span class="line"><span class="keyword">for</span> k <span class="keyword">in</span> <span class="built_in">range</span>(<span class="number">100</span>):</span><br><span class="line">    acr_x, fix_x, lr_x_w, lr_x_b = run_lr(X, Y_X)</span><br><span class="line">    acr_z, fix_z, lr_z_w, lr_z_b = run_lr(Z, Y_Z)</span><br><span class="line">    A = [[fix_x[<span class="number">0</span>][<span class="number">0</span>]/fix_x[<span class="number">0</span>].<span class="built_in">sum</span>(), fix_x[<span class="number">0</span>][<span class="number">1</span>]/fix_x[<span class="number">0</span>].<span class="built_in">sum</span>(), fix_x[<span class="number">0</span>][<span class="number">2</span>]/fix_x[<span class="number">0</span>].<span class="built_in">sum</span>()],</span><br><span class="line">         [fix_x[<span class="number">1</span>][<span class="number">0</span>]/fix_x[<span class="number">1</span>].<span class="built_in">sum</span>(), fix_x[<span class="number">1</span>][<span class="number">1</span>]/fix_x[<span class="number">1</span>].<span class="built_in">sum</span>(), fix_x[<span class="number">1</span>][<span class="number">2</span>]/fix_x[<span class="number">1</span>].<span class="built_in">sum</span>()],</span><br><span class="line">         [fix_x[<span class="number">2</span>][<span class="number">0</span>]/fix_x[<span class="number">2</span>].<span class="built_in">sum</span>(), fix_x[<span class="number">2</span>][<span class="number">1</span>]/fix_x[<span class="number">2</span>].<span class="built_in">sum</span>(), fix_x[<span class="number">2</span>][<span class="number">2</span>]/fix_x[<span class="number">2</span>].<span class="built_in">sum</span>()]</span><br><span class="line">         ]</span><br><span class="line"></span><br><span class="line">    P = []</span><br><span class="line">    <span class="keyword">for</span> j <span class="keyword">in</span> <span class="built_in">range</span>(<span class="built_in">int</span>(<span class="built_in">len</span>(data)/<span class="number">14</span>)):</span><br><span class="line">        O = []</span><br><span class="line">        <span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="built_in">len</span>(data)):</span><br><span class="line">            <span class="keyword">if</span> <span class="number">14</span> * j &lt;= i &lt; <span class="number">14</span> * (j + <span class="number">1</span>):</span><br><span class="line">                O.append(Y_X[i])</span><br><span class="line">        P.append(HMM.forward(Q, V, A, B, O, PI))</span><br><span class="line"></span><br><span class="line">    L = <span class="number">0</span></span><br><span class="line">    <span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="built_in">len</span>(P)):</span><br><span class="line">        L += math.log(P[i])</span><br><span class="line">    BIC = L - <span class="number">18</span> * (math.log(<span class="number">3108</span> / <span class="number">2</span>))</span><br><span class="line">    <span class="comment"># 保存似然值</span></span><br><span class="line">    list_A.append(A)</span><br><span class="line">    list_L.append(L)</span><br><span class="line">    list_BIC.append(BIC)</span><br><span class="line">    list_fix_x.append(fix_x)</span><br><span class="line">    list_fix_z.append(fix_z)</span><br><span class="line">    list_lr_x_w.append(lr_x_w)</span><br><span class="line">    list_lr_z_w.append(lr_z_w)</span><br><span class="line">    list_lr_x_b.append(lr_x_b)</span><br><span class="line">    list_lr_z_b.append(lr_z_b)</span><br><span class="line">    list_acr_x.append(acr_x)</span><br><span class="line">    list_acr_z.append(acr_z)</span><br><span class="line"></span><br><span class="line">print(<span class="string">f&#x27;百次循环后，最高准确率<span class="subst">&#123;<span class="built_in">max</span>(list_acr_x)&#125;</span>&#x27;</span>)</span><br><span class="line">print(<span class="string">f&#x27;最大准确率对应的序号：<span class="subst">&#123;list_acr_x.index(<span class="built_in">max</span>(list_acr_x))&#125;</span>&#x27;</span>)</span><br><span class="line">print()</span><br><span class="line">print(<span class="string">f&#x27;百次循环后，似然值为<span class="subst">&#123;list_L[list_acr_x.index(<span class="built_in">max</span>(list_acr_x))]&#125;</span>&#x27;</span>)</span><br><span class="line">print(<span class="string">f&#x27;对应的BIC为<span class="subst">&#123;list_BIC[list_acr_x.index(<span class="built_in">max</span>(list_acr_x))]&#125;</span>&#x27;</span>)</span><br><span class="line"></span><br><span class="line">print(<span class="string">f&#x27;在4个变量下的状态转移概率矩阵：<span class="subst">&#123;list_A[list_acr_x.index(<span class="built_in">max</span>(list_acr_x))]&#125;</span>&#x27;</span>)</span><br><span class="line">print(<span class="string">f&#x27;-&#x27;</span>*<span class="number">20</span>)</span><br><span class="line">print(<span class="string">f&#x27;参数估计&#x27;</span>)</span><br><span class="line">print(<span class="string">f&#x27;状态转移概率矩阵的系数为：<span class="subst">&#123;list_lr_x_w[list_acr_x.index(<span class="built_in">max</span>(list_acr_x))]&#125;</span>&#x27;</span>)</span><br><span class="line">print(<span class="string">f&#x27;状态转移概率矩阵的偏差为：<span class="subst">&#123;list_lr_x_b[list_acr_x.index(<span class="built_in">max</span>(list_acr_x))]&#125;</span>&#x27;</span>)</span><br><span class="line">print(<span class="string">f&#x27;观察状态概率转移矩阵的系数为：<span class="subst">&#123;list_lr_z_w[list_acr_x.index(<span class="built_in">max</span>(list_acr_x))]&#125;</span>&#x27;</span>)</span><br><span class="line">print(<span class="string">f&#x27;观察状态概率转移矩阵的偏差为：<span class="subst">&#123;list_lr_z_b[list_acr_x.index(<span class="built_in">max</span>(list_acr_x))]&#125;</span>&#x27;</span>)</span><br><span class="line"></span><br><span class="line">num = list_acr_x.index(<span class="built_in">max</span>(list_acr_x))</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">list_x = np.array(X).tolist()</span><br><span class="line">print(<span class="string">f&#x27;变量1下的知识贡献意愿转移概率&#x27;</span>)</span><br><span class="line">wx_b0 = []</span><br><span class="line">wx_b1 = []</span><br><span class="line">wx_b2 = []</span><br><span class="line"><span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="built_in">len</span>(data)):</span><br><span class="line">    <span class="keyword">if</span> Y_X[i] == <span class="number">0</span>:</span><br><span class="line">        wx_b0.append(list_lr_x_w[num][<span class="number">0</span>][<span class="number">0</span>] * list_x[i][<span class="number">0</span>] + list_lr_x_b[num][<span class="number">0</span>])</span><br><span class="line">    <span class="keyword">elif</span> Y_X[i] == <span class="number">1</span>:</span><br><span class="line">        wx_b1.append(list_lr_x_w[num][<span class="number">1</span>][<span class="number">0</span>] * list_x[i][<span class="number">0</span>] + list_lr_x_b[num][<span class="number">1</span>])</span><br><span class="line">    <span class="keyword">else</span>:</span><br><span class="line">        wx_b2.append(list_lr_x_w[num][<span class="number">2</span>][<span class="number">0</span>] * list_x[i][<span class="number">0</span>] + list_lr_x_b[num][<span class="number">2</span>])</span><br><span class="line"></span><br><span class="line"><span class="comment"># fig = plt.figure(figsize=(10, 8))</span></span><br><span class="line"><span class="comment"># plt.plot(np.array(wx_b0), &quot;bo&quot;, linewidth=1)</span></span><br><span class="line"><span class="comment"># plt.plot(np.array(wx_b2), &quot;ro&quot;, linewidth=1)</span></span><br><span class="line"><span class="comment"># plt.plot(np.array(wx_b1), &quot;ko&quot;, linewidth=1)</span></span><br><span class="line"><span class="comment"># plt.show()</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 状态1个数： len(wx_b0) = 2461</span></span><br><span class="line"><span class="comment"># 将其排序,状态1中设置260个</span></span><br><span class="line"><span class="comment"># 状态2时的个数： 538,设置为80， 400， 58</span></span><br><span class="line"><span class="comment"># 状态3时的个数：109 ， 在2中设置35个</span></span><br><span class="line"></span><br><span class="line">H = [[(<span class="built_in">len</span>(wx_b0) - <span class="number">260</span>)/<span class="built_in">len</span>(wx_b0), <span class="number">260</span>/<span class="built_in">len</span>(wx_b0), <span class="number">0</span>],</span><br><span class="line">     [(<span class="built_in">len</span>(wx_b1) - <span class="number">458</span>)/<span class="built_in">len</span>(wx_b1), <span class="number">400</span>/<span class="built_in">len</span>(wx_b1), <span class="number">58</span>/<span class="built_in">len</span>(wx_b1)],</span><br><span class="line">     [<span class="number">0</span>, <span class="number">15</span>/<span class="built_in">len</span>(wx_b2), <span class="number">1</span><span class="number">-15</span>/(<span class="built_in">len</span>(wx_b2))]]</span><br><span class="line">print(<span class="string">f&#x27;<span class="subst">&#123;H&#125;</span>&#x27;</span>)</span><br><span class="line"></span><br><span class="line">print(<span class="string">f&#x27;变量2下的知识贡献意愿转移概率&#x27;</span>)</span><br><span class="line">wx_b20 = []</span><br><span class="line">wx_b21 = []</span><br><span class="line">wx_b22 = []</span><br><span class="line"><span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="built_in">len</span>(data)):</span><br><span class="line">    <span class="keyword">if</span> Y_X[i] == <span class="number">0</span>:</span><br><span class="line">        wx_b20.append(list_lr_x_w[num][<span class="number">0</span>][<span class="number">1</span>] * list_x[i][<span class="number">1</span>] + list_lr_x_b[num][<span class="number">0</span>])</span><br><span class="line">    <span class="keyword">elif</span> Y_X[i] == <span class="number">1</span>:</span><br><span class="line">        wx_b21.append(list_lr_x_w[num][<span class="number">1</span>][<span class="number">1</span>] * list_x[i][<span class="number">1</span>] + list_lr_x_b[num][<span class="number">1</span>])</span><br><span class="line">    <span class="keyword">else</span>:</span><br><span class="line">        wx_b22.append(list_lr_x_w[num][<span class="number">2</span>][<span class="number">1</span>] * list_x[i][<span class="number">1</span>] + list_lr_x_b[num][<span class="number">2</span>])</span><br><span class="line"></span><br><span class="line"><span class="comment"># fig = plt.figure(figsize=(10, 8))</span></span><br><span class="line"><span class="comment"># plt.plot(np.array(wx_b20), &quot;bo&quot;, linewidth=1)</span></span><br><span class="line"><span class="comment"># plt.plot(np.array(wx_b22), &quot;ro&quot;, linewidth=1)</span></span><br><span class="line"><span class="comment"># plt.plot(np.array(wx_b21), &quot;ko&quot;, linewidth=1)</span></span><br><span class="line"><span class="comment"># plt.show()</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 状态2个数： len(wx_b0) = 2461</span></span><br><span class="line"><span class="comment"># 将其排序,   状态1中设置260个</span></span><br><span class="line"><span class="comment"># 状态2时的个数： 538,设置为80， 400， 58</span></span><br><span class="line"><span class="comment"># 状态3时的个数：109 ， 在2中设置35个</span></span><br><span class="line"></span><br><span class="line">H2 = [[(<span class="built_in">len</span>(wx_b20) - <span class="number">360</span>)/<span class="built_in">len</span>(wx_b20), <span class="number">360</span>/<span class="built_in">len</span>(wx_b20), <span class="number">0</span>],</span><br><span class="line">      [(<span class="built_in">len</span>(wx_b21) - <span class="number">500</span>)/<span class="built_in">len</span>(wx_b21), <span class="number">450</span>/<span class="built_in">len</span>(wx_b21), <span class="number">50</span>/<span class="built_in">len</span>(wx_b21)],</span><br><span class="line">      [<span class="number">0</span>, <span class="number">16</span>/<span class="built_in">len</span>(wx_b22), <span class="number">1</span><span class="number">-16</span>/(<span class="built_in">len</span>(wx_b22))]]</span><br><span class="line">print(<span class="string">f&#x27;<span class="subst">&#123;H2&#125;</span>&#x27;</span>)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">print(<span class="string">f&#x27;变量3下的知识贡献意愿转移概率&#x27;</span>)</span><br><span class="line">wx_b30 = []</span><br><span class="line">wx_b31 = []</span><br><span class="line">wx_b32 = []</span><br><span class="line"><span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="built_in">len</span>(data)):</span><br><span class="line">    <span class="keyword">if</span> Y_X[i] == <span class="number">0</span>:</span><br><span class="line">        wx_b30.append(list_lr_x_w[num][<span class="number">0</span>][<span class="number">2</span>] * list_x[i][<span class="number">2</span>] + list_lr_x_b[num][<span class="number">0</span>])</span><br><span class="line">    <span class="keyword">elif</span> Y_X[i] == <span class="number">1</span>:</span><br><span class="line">        wx_b31.append(list_lr_x_w[num][<span class="number">1</span>][<span class="number">2</span>] * list_x[i][<span class="number">2</span>] + list_lr_x_b[num][<span class="number">1</span>])</span><br><span class="line">    <span class="keyword">else</span>:</span><br><span class="line">        wx_b32.append(list_lr_x_w[num][<span class="number">2</span>][<span class="number">2</span>] * list_x[i][<span class="number">2</span>] + list_lr_x_b[num][<span class="number">2</span>])</span><br><span class="line"></span><br><span class="line"><span class="comment"># fig = plt.figure(figsize=(10, 8))</span></span><br><span class="line"><span class="comment"># plt.plot(np.array(wx_b30), &quot;bo&quot;, linewidth=1)</span></span><br><span class="line"><span class="comment"># plt.plot(np.array(wx_b32), &quot;ro&quot;, linewidth=1)</span></span><br><span class="line"><span class="comment"># plt.plot(np.array(wx_b31), &quot;ko&quot;, linewidth=1)</span></span><br><span class="line"><span class="comment"># plt.show()</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 状态2个数： len(wx_b0) = 2461</span></span><br><span class="line"><span class="comment"># 将其排序,   状态1中设置260个</span></span><br><span class="line"><span class="comment"># 状态2时的个数： 538,设置为80， 400， 58</span></span><br><span class="line"><span class="comment"># 状态3时的个数：109 ， 在2中设置35个</span></span><br><span class="line"></span><br><span class="line">H3 = [[(<span class="built_in">len</span>(wx_b30) - <span class="number">361</span>)/<span class="built_in">len</span>(wx_b30), <span class="number">361</span>/<span class="built_in">len</span>(wx_b30), <span class="number">0</span>],</span><br><span class="line">      [(<span class="built_in">len</span>(wx_b31) - <span class="number">501</span>)/<span class="built_in">len</span>(wx_b31), <span class="number">451</span>/<span class="built_in">len</span>(wx_b31), <span class="number">50</span>/<span class="built_in">len</span>(wx_b31)],</span><br><span class="line">      [<span class="number">0</span>, <span class="number">12</span>/<span class="built_in">len</span>(wx_b32), <span class="number">1</span><span class="number">-12</span>/(<span class="built_in">len</span>(wx_b32))]]</span><br><span class="line">print(<span class="string">f&#x27;<span class="subst">&#123;H3&#125;</span>&#x27;</span>)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">print(<span class="string">f&#x27;变量4下的知识贡献意愿转移概率&#x27;</span>)</span><br><span class="line">wx_b40 = []</span><br><span class="line">wx_b41 = []</span><br><span class="line">wx_b42 = []</span><br><span class="line"><span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="built_in">len</span>(data)):</span><br><span class="line">    <span class="keyword">if</span> Y_X[i] == <span class="number">0</span>:</span><br><span class="line">        wx_b40.append(list_lr_x_w[num][<span class="number">0</span>][<span class="number">3</span>] * list_x[i][<span class="number">3</span>] + list_lr_x_b[num][<span class="number">0</span>])</span><br><span class="line">    <span class="keyword">elif</span> Y_X[i] == <span class="number">1</span>:</span><br><span class="line">        wx_b41.append(list_lr_x_w[num][<span class="number">1</span>][<span class="number">3</span>] * list_x[i][<span class="number">3</span>] + list_lr_x_b[num][<span class="number">1</span>])</span><br><span class="line">    <span class="keyword">else</span>:</span><br><span class="line">        wx_b42.append(list_lr_x_w[num][<span class="number">2</span>][<span class="number">3</span>] * list_x[i][<span class="number">3</span>] + list_lr_x_b[num][<span class="number">2</span>])</span><br><span class="line"></span><br><span class="line"><span class="comment"># fig = plt.figure(figsize=(10, 8))</span></span><br><span class="line"><span class="comment"># plt.plot(np.array(wx_b40), &quot;bo&quot;, linewidth=1)</span></span><br><span class="line"><span class="comment"># plt.plot(np.array(wx_b42), &quot;ro&quot;, linewidth=1)</span></span><br><span class="line"><span class="comment"># plt.plot(np.array(wx_b41), &quot;ko&quot;, linewidth=1)</span></span><br><span class="line"><span class="comment"># plt.show()</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 状态2个数： len(wx_b0) = 2461</span></span><br><span class="line"><span class="comment"># 将其排序,   状态1中设置260个</span></span><br><span class="line"><span class="comment"># 状态2时的个数： 538,设置为80， 400， 58</span></span><br><span class="line"><span class="comment"># 状态3时的个数：109 ， 在2中设置35个</span></span><br><span class="line"></span><br><span class="line">H4 = [[(<span class="built_in">len</span>(wx_b40) - <span class="number">361</span>)/<span class="built_in">len</span>(wx_b40), <span class="number">361</span>/<span class="built_in">len</span>(wx_b40), <span class="number">0</span>],</span><br><span class="line">      [(<span class="built_in">len</span>(wx_b41) - <span class="number">501</span>)/<span class="built_in">len</span>(wx_b41), <span class="number">451</span>/<span class="built_in">len</span>(wx_b41), <span class="number">50</span>/<span class="built_in">len</span>(wx_b41)],</span><br><span class="line">      [<span class="number">0</span>, <span class="number">12</span>/<span class="built_in">len</span>(wx_b42), <span class="number">1</span><span class="number">-12</span>/(<span class="built_in">len</span>(wx_b42))]]</span><br><span class="line">print(<span class="string">f&#x27;<span class="subst">&#123;H4&#125;</span>&#x27;</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment"># 全部数值下</span></span><br><span class="line">print(<span class="string">f&#x27;全部变量下的知识贡献意愿转移概率&#x27;</span>)</span><br><span class="line">wx_ba0 = []</span><br><span class="line">wx_ba1 = []</span><br><span class="line">wx_ba2 = []</span><br><span class="line"><span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="built_in">len</span>(data)):</span><br><span class="line">    <span class="keyword">if</span> Y_X[i] == <span class="number">0</span>:</span><br><span class="line">        wx_ba0.append(list_lr_x_w[num][<span class="number">0</span>][<span class="number">0</span>] * list_x[i][<span class="number">0</span>] +</span><br><span class="line">                      list_lr_x_w[num][<span class="number">0</span>][<span class="number">1</span>] * list_x[i][<span class="number">1</span>] +</span><br><span class="line">                      list_lr_x_w[num][<span class="number">0</span>][<span class="number">2</span>] * list_x[i][<span class="number">2</span>] +</span><br><span class="line">                      list_lr_x_w[num][<span class="number">0</span>][<span class="number">3</span>] * list_x[i][<span class="number">3</span>] +</span><br><span class="line">                      list_lr_x_b[num][<span class="number">0</span>])</span><br><span class="line">    <span class="keyword">elif</span> Y_X[i] == <span class="number">1</span>:</span><br><span class="line">        wx_ba1.append(list_lr_x_w[num][<span class="number">1</span>][<span class="number">0</span>] * list_x[i][<span class="number">0</span>] +</span><br><span class="line">                      list_lr_x_w[num][<span class="number">1</span>][<span class="number">1</span>] * list_x[i][<span class="number">1</span>] +</span><br><span class="line">                      list_lr_x_w[num][<span class="number">1</span>][<span class="number">2</span>] * list_x[i][<span class="number">2</span>] +</span><br><span class="line">                      list_lr_x_w[num][<span class="number">1</span>][<span class="number">3</span>] * list_x[i][<span class="number">3</span>] +</span><br><span class="line">                      list_lr_x_b[num][<span class="number">1</span>])</span><br><span class="line">    <span class="keyword">else</span>:</span><br><span class="line">        wx_ba2.append(list_lr_x_w[num][<span class="number">2</span>][<span class="number">0</span>] * list_x[i][<span class="number">0</span>] +</span><br><span class="line">                      list_lr_x_w[num][<span class="number">2</span>][<span class="number">1</span>] * list_x[i][<span class="number">1</span>] +</span><br><span class="line">                      list_lr_x_w[num][<span class="number">2</span>][<span class="number">2</span>] * list_x[i][<span class="number">2</span>] +</span><br><span class="line">                      list_lr_x_w[num][<span class="number">2</span>][<span class="number">3</span>] * list_x[i][<span class="number">3</span>] +</span><br><span class="line">                      list_lr_x_b[num][<span class="number">2</span>])</span><br><span class="line"><span class="comment"># 进行排序</span></span><br><span class="line">wx_ba0.sort()</span><br><span class="line">wx_ba1.sort()</span><br><span class="line">wx_ba2.sort()</span><br><span class="line"><span class="comment"># 找到边界,意思就是找到相对应的u1,u2-1,u2-h,u-3</span></span><br><span class="line"><span class="comment"># 我是这样理解的，其实对应的就是x_b的系数，但是少了一个而已</span></span><br><span class="line">b = list_fix_x[num][<span class="number">0</span>][<span class="number">1</span>]/<span class="built_in">sum</span>(list_fix_x[num][<span class="number">0</span>])</span><br><span class="line">x = <span class="built_in">len</span>(wx_ba0) * b</span><br><span class="line"><span class="comment"># 即根据前面那个</span></span><br><span class="line"><span class="comment"># 取倒数第16个作为边界吧</span></span><br><span class="line">u1 = wx_b0[<span class="number">-16</span>]</span><br><span class="line">b1 = list_fix_x[num][<span class="number">1</span>][<span class="number">0</span>]/<span class="built_in">sum</span>(list_fix_x[num][<span class="number">1</span>])</span><br><span class="line">x1 = <span class="built_in">len</span>(wx_ba1) * b1</span><br><span class="line">u2_1 = wx_ba1[<span class="built_in">int</span>(x1)]</span><br><span class="line">b2 = list_fix_x[num][<span class="number">1</span>][<span class="number">2</span>]/<span class="built_in">sum</span>(list_fix_x[num][<span class="number">1</span>])</span><br><span class="line">x2 = <span class="built_in">len</span>(wx_ba1) * b2</span><br><span class="line">u2_h = wx_ba1[-<span class="built_in">int</span>(x2)]</span><br><span class="line"></span><br><span class="line">b3 = list_fix_x[num][<span class="number">2</span>][<span class="number">2</span>]/<span class="built_in">sum</span>(list_fix_x[num][<span class="number">2</span>])</span><br><span class="line">x4 = <span class="built_in">len</span>(wx_b2) * b3</span><br><span class="line">u3 = wx_ba2[-<span class="built_in">int</span>(x4)]</span><br><span class="line">print(<span class="string">f&#x27;u1=<span class="subst">&#123;u1&#125;</span>,u2_1=<span class="subst">&#123;u2_1&#125;</span>,u2_h=<span class="subst">&#123;u2_h&#125;</span>, u3=<span class="subst">&#123;u3&#125;</span>&#x27;</span>)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">print(<span class="string">f&#x27;状态转移概率矩阵的系数为：<span class="subst">&#123;list_lr_x_w[list_acr_x.index(<span class="built_in">max</span>(list_acr_x))]&#125;</span>&#x27;</span>)</span><br><span class="line"></span><br><span class="line">print(<span class="string">f&#x27;观察状态概率转移矩阵的系数为：<span class="subst">&#123;list_lr_z_w[list_acr_x.index(<span class="built_in">max</span>(list_acr_x))]&#125;</span>&#x27;</span>)</span><br><span class="line">print(<span class="string">f&#x27;观察状态概率转移矩阵的截距为：<span class="subst">&#123;list_lr_z_b[list_acr_x.index(<span class="built_in">max</span>(list_acr_x))]&#125;</span>&#x27;</span>)</span><br><span class="line"></span><br><span class="line">print(<span class="string">f&#x27;所有参数和矩阵表格如上&#x27;</span>)</span><br></pre></td></tr></table></figure>

<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br></pre></td><td class="code"><pre><span class="line">百次循环后，最高准确率<span class="number">0.917470525187567</span></span><br><span class="line">最大准确率对应的序号：<span class="number">29</span></span><br><span class="line"></span><br><span class="line">百次循环后，似然值为<span class="number">-1355.7570132278736</span></span><br><span class="line">对应的BIC为<span class="number">-1488.0315887845702</span></span><br><span class="line">在<span class="number">4</span>个变量下的状态转移概率矩阵：[[<span class="number">0.9868073878627969</span>, <span class="number">0.013192612137203167</span>, <span class="number">0.0</span>], [<span class="number">0.40816326530612246</span>, <span class="number">0.5782312925170068</span>, <span class="number">0.013605442176870748</span>], [<span class="number">0.0</span>, <span class="number">0.17857142857142858</span>, <span class="number">0.8214285714285714</span>]]</span><br><span class="line">--------------------</span><br><span class="line">参数估计</span><br><span class="line">状态转移概率矩阵的系数为：[[<span class="number">-0.07814258</span> <span class="number">-0.08035225</span> <span class="number">-0.03518065</span> <span class="number">-8.30153077</span>]</span><br><span class="line"> [<span class="number">-0.07992528</span>  <span class="number">0.07019997</span> <span class="number">-0.02918073</span>  <span class="number">2.04945495</span>]</span><br><span class="line"> [ <span class="number">0.15806786</span>  <span class="number">0.01015228</span>  <span class="number">0.06436137</span>  <span class="number">6.25207582</span>]]</span><br><span class="line">状态转移概率矩阵的偏差为：[ <span class="number">1.46433444</span>  <span class="number">1.09085289</span> <span class="number">-2.55518733</span>]</span><br><span class="line">观察状态概率转移矩阵的系数为：[[ <span class="number">0.44462513</span>  <span class="number">0.22701876</span>]</span><br><span class="line"> [ <span class="number">0.48690629</span> <span class="number">-0.33289007</span>]</span><br><span class="line"> [<span class="number">-0.93153142</span>  <span class="number">0.10587131</span>]]</span><br><span class="line">观察状态概率转移矩阵的偏差为：[ <span class="number">2.26772789</span> <span class="number">-0.16557564</span> <span class="number">-2.10215226</span>]</span><br><span class="line">变量<span class="number">1</span>下的知识贡献意愿转移概率</span><br><span class="line">[[<span class="number">0.8943518894758228</span>, <span class="number">0.10564811052417716</span>, <span class="number">0</span>], [<span class="number">0.14869888475836432</span>, <span class="number">0.7434944237918215</span>, <span class="number">0.10780669144981413</span>], [<span class="number">0</span>, <span class="number">0.13761467889908258</span>, <span class="number">0.8623853211009174</span>]]</span><br><span class="line">变量<span class="number">2</span>下的知识贡献意愿转移概率</span><br><span class="line">[[<span class="number">0.8537180008126778</span>, <span class="number">0.14628199918732224</span>, <span class="number">0</span>], [<span class="number">0.07063197026022305</span>, <span class="number">0.8364312267657993</span>, <span class="number">0.09293680297397769</span>], [<span class="number">0</span>, <span class="number">0.14678899082568808</span>, <span class="number">0.8532110091743119</span>]]</span><br><span class="line">变量<span class="number">3</span>下的知识贡献意愿转移概率</span><br><span class="line">[[<span class="number">0.8533116619260463</span>, <span class="number">0.14668833807395368</span>, <span class="number">0</span>], [<span class="number">0.0687732342007435</span>, <span class="number">0.8382899628252788</span>, <span class="number">0.09293680297397769</span>], [<span class="number">0</span>, <span class="number">0.11009174311926606</span>, <span class="number">0.8899082568807339</span>]]</span><br><span class="line">变量<span class="number">4</span>下的知识贡献意愿转移概率</span><br><span class="line">[[<span class="number">0.8533116619260463</span>, <span class="number">0.14668833807395368</span>, <span class="number">0</span>], [<span class="number">0.0687732342007435</span>, <span class="number">0.8382899628252788</span>, <span class="number">0.09293680297397769</span>], [<span class="number">0</span>, <span class="number">0.11009174311926606</span>, <span class="number">0.8899082568807339</span>]]</span><br><span class="line">全部变量下的知识贡献意愿转移概率</span><br><span class="line">u1=<span class="number">1.4980410992089837</span>,u2_1=<span class="number">0.8129063006054411</span>,u2_h=<span class="number">2.8303668243942806</span>, u3=<span class="number">2.68524912411076</span></span><br><span class="line">状态转移概率矩阵的系数为：[[<span class="number">-0.07814258</span> <span class="number">-0.08035225</span> <span class="number">-0.03518065</span> <span class="number">-8.30153077</span>]</span><br><span class="line"> [<span class="number">-0.07992528</span>  <span class="number">0.07019997</span> <span class="number">-0.02918073</span>  <span class="number">2.04945495</span>]</span><br><span class="line"> [ <span class="number">0.15806786</span>  <span class="number">0.01015228</span>  <span class="number">0.06436137</span>  <span class="number">6.25207582</span>]]</span><br><span class="line">观察状态概率转移矩阵的系数为：[[ <span class="number">0.44462513</span>  <span class="number">0.22701876</span>]</span><br><span class="line"> [ <span class="number">0.48690629</span> <span class="number">-0.33289007</span>]</span><br><span class="line"> [<span class="number">-0.93153142</span>  <span class="number">0.10587131</span>]]</span><br><span class="line">观察状态概率转移矩阵的截距为：[ <span class="number">2.26772789</span> <span class="number">-0.16557564</span> <span class="number">-2.10215226</span>]</span><br><span class="line">所有参数和矩阵表格如上</span><br></pre></td></tr></table></figure>





<p><img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1594399298975&di=10b635fa56f834e6a4afb58286e8c847&imgtype=0&src=http://i0.hdslb.com/bfs/article/b6d8d812ef63e040bd944da29effa95001176a20.jpg"></p>

    </div>
</article>


                </div>
                <aside class="col-md-4 gal-left" id="sidebar">
    <!-- 此为sidebar的搜索框, 非搜索结果页面 -->
<aside id="sidebar-search">
    <div class="search hidden-xs" data-aos="fade-up" data-aos-duration="2000">
        <form class="form-inline clearfix" id="search-form" method="get"
              action="/search/index.html">
            <input type="text" name="s" class="form-control" id="searchInput" placeholder="搜索文章~" autocomplete="off">
            <button class="btn btn-danger btn-gal" type="submit">
                <i class="fa fa-search"></i>
            </button>
        </form>
    </div>
</aside>
    <aside id="sidebar-author">
    <div class="panel panel-gal" data-aos="flip-right" data-aos-duration="3000">
        <div class="panel-heading" style="text-align: center">
            <i class="fa fa-quote-left"></i>
            esy
            <i class="fa fa-quote-right"></i>
        </div>
        <div class="author-panel text-center">
            <img src="/imgs/avatar.jpg" width="140" height="140"
                 alt="个人头像" class="author-image">
            <p class="author-description"><p>esy</p>
</p>
        </div>
    </div>
</aside>
    
    <aside id="sidebar-recent_comments">
    <div class="panel panel-gal recent hidden-xs" data-aos="fade-up" data-aos-duration="2000">
        <div class="panel-heading">
            <i class="fa fa-comments"></i>
            最新评论
            <i class="fa fa-times-circle panel-remove"></i>
            <i class="fa fa-chevron-circle-up panel-toggle"></i>
        </div>
        <ul class="list-group list-group-flush"></ul>
    </div>
</aside>
    
    <!-- 要配置好leancloud才能开启此小工具 -->
    
    
    <aside id="sidebar-recent_posts">
    <div class="panel panel-gal recent hidden-xs" data-aos="fade-up" data-aos-duration="2000">
        <div class="panel-heading">
            <i class="fa fa-refresh"></i>
            近期文章
            <i class="fa fa-times-circle panel-remove"></i>
            <i class="fa fa-chevron-circle-up panel-toggle"></i>
        </div>
        <ul class="list-group list-group-flush">
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/11/05/python%20work/%E6%9C%80%E5%B0%8F%E4%BA%8C%E4%B9%98%E6%B3%95/">最小二乘法</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/11/05/python%20work/%E7%BB%9F%E8%AE%A1%E5%AD%A6%E4%B9%A0-%E7%AC%AC%E4%B8%80%E7%AB%A0/">统计学习--第一章</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/11/04/python%20work/hello-world/">Hello World</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/11/03/python%20work/%E5%88%86%E7%B1%BB%E6%A8%A1%E5%9E%8B%E7%9A%84%E8%AF%84%E4%BC%B0%E6%8C%87%E6%A0%87/">分类模型的评估指标</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/10/21/python%20work/10-21-%E7%88%AC%E8%99%AB%E5%9F%BA%E7%A1%80/">10-21 爬虫基础</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/09/25/python%20work/CRF%E7%9A%84%E6%95%B4%E4%BD%93%E6%B5%81%E7%A8%8B%E7%BB%93%E6%9E%9C/">CRF的整体流程结果</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/09/25/python%20work/nlp-crf%E6%A8%A1%E5%9E%8B/">nlp_crf模型</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/09/25/python%20work/%E6%95%B0%E5%AD%A6%E5%BB%BA%E6%A8%A1%E9%97%AE%E9%A2%983/">数学建模问题3</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/09/25/python%20work/%E6%95%B0%E5%AD%A6%E5%BB%BA%E6%A8%A1%E9%97%AE%E9%A2%982/">数学建模问题2</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/09/25/python%20work/%E6%95%B0%E5%AD%A6%E5%BB%BA%E6%A8%A1%E9%97%AE%E9%A2%981/">数学建模问题1</a>
                </span>
            </li>
            
        </ul>
    </div>
</aside>
    
    
    <aside id="sidebar-rand_posts">
    <div class="panel panel-gal recent hidden-xs" data-aos="fade-up" data-aos-duration="2000">
        <div class="panel-heading">
            <i class="fa fa-refresh"></i>
            随机文章
            <i class="fa fa-times-circle panel-remove"></i>
            <i class="fa fa-chevron-circle-up panel-toggle"></i>
        </div>
        <ul class="list-group list-group-flush">
            
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/08/08/python%20work/UI%E7%95%8C%E9%9D%A2%E7%BE%8E%E5%8C%96/">UI界面美化</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/08/18/python%20work/edf%E6%96%87%E4%BB%B6%E4%B8%AD%E7%9A%84%E6%95%B0%E6%8D%AE%E8%AF%BB%E5%8F%96/">edf文件中的数据读取</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/08/08/python%20work/gensim%E4%B8%AD%E7%9A%84tfidf/">gensim中的tfidf</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/01/07/python%20work/matlab%E4%B8%AD%E7%9A%84%E6%BB%91%E5%8A%A8%E7%AA%97%E5%8F%A3/">matlab中的滑动窗口</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/05/05/python%20work/python-opencv%E5%9F%BA%E7%A1%80%E5%85%A5%E9%97%A8/">python-opencv基础入门</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/05/26/python%20work/python-%E5%85%A5%E9%97%A8%E5%A4%8D%E4%B9%A0%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A1/">python-入门复习面向对象</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2019/12/01/python%20work/python%E5%9F%BA%E7%A1%80%E4%B9%8B%E7%BB%98%E5%88%B6%E5%88%97%E8%A1%A8%E6%96%87%E4%BB%B6/">LV-1</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/07/02/python%20work/%E4%BA%A4%E5%8F%89%E9%AA%8C%E8%AF%81/">交叉验证</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/09/22/python%20work/%E6%95%B0%E5%AD%A6%E5%BB%BA%E6%A8%A1%E5%92%8C%E5%88%86%E6%9E%90/">数学建模和分析</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/08/23/python%20work/%E7%89%B9%E5%BE%81%E9%80%89%E6%8B%A9%E7%9A%84%E6%96%B0%E7%90%86%E8%A7%A3%E5%92%8C%E6%9B%B4%E6%94%B9/">特征选择的新理解和更改</a>
                </span>
            </li>
            
        </ul>
    </div>
</aside>
    
    
    <aside id="gal-sets">
        <div class="panel panel-gal hidden-xs" data-aos="fade-up" data-aos-duration="2000">
            <ul class="nav nav-pills pills-gal">

                
                <li>
                    <a href="/2020/07/09/python%20work/HMM%E4%B9%8B%E6%95%B0%E6%8D%AE%E7%9A%84%E5%A4%84%E7%90%86/index.html#sidebar-tags" data-toggle="tab" id="tags-tab">热门标签</a>
                </li>
                
                
                <li>
                    <a href="/2020/07/09/python%20work/HMM%E4%B9%8B%E6%95%B0%E6%8D%AE%E7%9A%84%E5%A4%84%E7%90%86/index.html#sidebar-friend-links" data-toggle="tab" id="friend-links-tab">友情链接</a>
                </li>
                
                
                <li>
                    <a href="/2020/07/09/python%20work/HMM%E4%B9%8B%E6%95%B0%E6%8D%AE%E7%9A%84%E5%A4%84%E7%90%86/index.html#sidebar-links" data-toggle="tab" id="links-tab">个人链接</a>
                </li>
                
            </ul>
            <div class="tab-content">
                
                <div class="cloud-tags tab-pane nav bs-sidenav fade" id="sidebar-tags">
    
    <a href="/tags/py-study/" style="font-size: 12.883749180370401px;" class="tag-cloud-link">py_study</a>
    
    <a href="/tags/nlp/" style="font-size: 12.640881721426119px;" class="tag-cloud-link">nlp</a>
    
    <a href="/tags/Graduation-work/" style="font-size: 14.30051834851249px;" class="tag-cloud-link">Graduation work</a>
    
    <a href="/tags/work/" style="font-size: 19.220192489441963px;" class="tag-cloud-link">work</a>
    
    <a href="/tags/hexo/" style="font-size: 15.681181134159846px;" class="tag-cloud-link">hexo</a>
    
    <a href="/tags/%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA/" style="font-size: 18.904140435842063px;" class="tag-cloud-link">-个人博客搭建</a>
    
    <a href="/tags/malab-%E6%AF%95%E4%B8%9A/" style="font-size: 10.239841069334393px;" class="tag-cloud-link">-malab -毕业</a>
    
    <a href="/tags/python-%E4%BA%BA%E5%B7%A5%E6%99%BA%E8%83%BD/" style="font-size: 10.016251454115203px;" class="tag-cloud-link">-python -人工智能</a>
    
    <a href="/tags/python/" style="font-size: 19.08086763705728px;" class="tag-cloud-link">python</a>
    
    <a href="/tags/python/" style="font-size: 13.645168418269602px;" class="tag-cloud-link">-python</a>
    
    <a href="/tags/mathematical-modeling/" style="font-size: 10.68497373146959px;" class="tag-cloud-link">mathematical modeling</a>
    
    <a href="/tags/statistical-learning/" style="font-size: 17.025606879782604px;" class="tag-cloud-link">statistical learning</a>
    
</div>
                
                
                <div class="friend-links tab-pane nav bs-sidenav fade" id="sidebar-friend-links">
    
    <li>
        <a href="http://kdays.net/days/" target="_blank">KDays Forum</a>
    </li>
    
    <li>
        <a href="http://www.gal123.com/" target="_blank">绅士导航♂</a>
    </li>
    
    <li>
        <a href="http://www.moe123.com/" target="_blank">萌导航</a>
    </li>
    
</div>
                
                
                <div class="links tab-pane nav bs-sidenav fade" id="sidebar-links">
    
    <li>
        <a href="https://github.com/ZEROKISEKI/" target="_blank">Github</a>
    </li>
    
    <li>
        <a href="https://coding.net/u/SORA1" target="_blank">Coding</a>
    </li>
    
    <li>
        <a href="https://www.zhihu.com/people/aonosora/activities" target="_blank">知乎</a>
    </li>
    
</div>
                
            </div>
        </div>
    </aside>
    
</aside>
            </div>
        </div>
    </div>
    <footer id="gal-footer">
    <div class="container">
        Copyright © 2018 esy Powered by <a href="https://hexo.io/" target="_blank">Hexo</a>.&nbsp;Theme by <a href="https://github.com/ZEROKISEKI" target="_blank">AONOSORA</a>
    </div>
</footer>

<!-- 回到顶端 -->
<div id="gal-gotop">
    <i class="fa fa-angle-up"></i>
</div>
</body>

<script src="/js/activate-power-mode.js"></script>

<script>

    // 配置highslide
	hs.graphicsDir = '/js/highslide/graphics/'
    hs.outlineType = "rounded-white";
    hs.dimmingOpacity = 0.8;
    hs.outlineWhileAnimating = true;
    hs.showCredits = false;
    hs.captionEval = "this.thumb.alt";
    hs.numberPosition = "caption";
    hs.align = "center";
    hs.transitions = ["expand", "crossfade"];
    hs.lang.number = '共%2张图, 当前是第%1张';
    hs.addSlideshow({
      interval: 5000,
      repeat: true,
      useControls: true,
      fixedControls: "fit",
      overlayOptions: {
        opacity: 0.75,
        position: "bottom center",
        hideOnMouseOut: true
      }
    })

    // 初始化aos
    AOS.init({
      duration: 1000,
      delay: 0,
      easing: 'ease-out-back'
    });

</script>
<script>
	POWERMODE.colorful = 'true';    // make power mode colorful
	POWERMODE.shake = 'true';       // turn off shake
	// TODO 这里根据具体情况修改
	document.body.addEventListener('input', POWERMODE);
</script>
<script>
    window.slideConfig = {
      prefix: '/imgs/slide/background',
      ext: 'jpg',
      maxCount: '6'
    }
</script>

<script src="/js/hs.js"></script>
<script src="/js/blog.js"></script>



<script src="/js/oni.js"></script>




</html>